package top.infopub.mgr.mkt.service.impl;

import com.alibaba.fastjson.JSON;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.infopub.mgr.common.vo.RspVo;
import top.infopub.mgr.mkt.dao.ProjectSubInfoDao;
import top.infopub.mgr.mkt.service.ProjectSubInfoService;
import top.infopub.mgr.mkt.vo.InvestmentInfoVo;
import top.infopub.model.mkt.ProjectSubInfo;
import top.infopub.security.vo.AuthorizationVO;

@Service
public class ProjectSubInfoServiceImpl implements ProjectSubInfoService {
    @Autowired
    private ProjectSubInfoDao projectSubInfoDao;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveOrUpt(AuthorizationVO authVo) {
        //处理数据，把行合计和列合计整合成两个字符串
        //删除数据库中原来的表格数据，条件(proCode)
        //把提交的表格数据保存到数据库表中
    }

    @Override
    public RspVo selectByProCode(String proCode) {
       ProjectSubInfo projectSubInfo =  projectSubInfoDao.queryByProCode(proCode);
        String contentJson = projectSubInfo.getContentJson();
        InvestmentInfoVo investmentInfoVo = JSON.parseObject(contentJson, InvestmentInfoVo.class);
        return RspVo.getSuccessResponse(investmentInfoVo);
    }
}
